Skip to content

Give the combobox, the Treeview cells, and the classic widgets the spacing scale - #1102

Open
beetlebugorg wants to merge 4 commits into
mainfrom
theme-paddings
Open

beetlebugorg wants to merge 4 commits into
mainfrom
theme-paddings

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

Stacked on #1090. The rest of #1070 in the modern look, from the spacing scale of modern.css (--space-1 to --space-5).

Summary

  • Combobox margin. TCombobox { margin: var(--space-1) } keeps room for the focus ring inside the window, as TButton -margin does.

    • The entry code draws the field in the box inside the margin (entry.frameRect). It also finds the text and the arrow there, and places the list there, so a click lands where the field is drawn.
    • identify gives an empty string in the margin.
    • ttk::style lookup TCombobox -margin gives 2.
  • Treeview cells and headings. Treeview::item and Treeview::heading have the padding var(--space-2) var(--space-3). The heading was 5 8 before.

    • ttk::style lookup of -padding for the styles Item and Heading, also Treeview.Item and Treeview.Heading with classes before them, gives 8 4.
    • configure of these styles writes a rule for the part ::item or ::heading.
  • Classic widgets.

    Widget Before After
    Button 6 12 4 12
    Entry 5 8 4 8
    Checkbutton, Radiobutton 3 2 2
    Labelframe 10 12 8 12

    When the script did not set the option, cget of -padx, -pady, and -highlightthickness gives the padding and the width of the focus ring that the look draws. This applies to button, label, entry, checkbutton, radiobutton, and labelframe. These are the new style props padx, pady, and focus_ring.

  • Docs: docs/styling.md (the table of the space of the theme and a table of the classic widgets) and docs/differences.md.

Fixes #1091

Pictures

The changed goldens are the before and after pictures: see the image diff of tests/golden/button-*.png, entry-*.png, demo-*.png, and grapheme-shot-*.png. examples/debug/golden-order.png is also made again. The numbers of docs/debug/visual-diff.md, docs/debug/input.md, and tests/debug-examples.sh follow the new size of the window.

Tests

  • zig build test passes, with a new test in src/tests/ttk.zig. It checks:
    • the cget values of each classic widget, and a value of the script that wins;
    • the lookup of Item and Heading, and the height of a row after configure Item -padding;
    • the margin of a combobox in its request height, and identify in the margin and on the arrow.
  • Three tests have the new values:
    • The entry's -highlightthickness is 2, the focus ring. The default stays 1, as in wish.
    • lookup TButton -padding gives 12 4.
    • The Login button of the notebook test is 31 high, and 27 with -margin 0.
  • tests/debug-examples.sh passes.
  • sh tools/ref-check.sh has only the 6 failures of Give the ttk widgets the space of the modern theme #1090, in docs/reference/ttk-notebook.tcl.

A theme of Tk puts space in a few places, so a script with little -padx
of its own still has room. ztk gave those places about 0, so the Login
dialog of tkchat had no margins. The modern theme now fills them from a
new spacing scale (--space-1 to --space-5):

- the notebook insets its tabs and its client area from its edge, keeps
  margins around the row of tabs (the part ::tabs), and insets the page
  inside the client area;
- a ttk button, check button, radio button, and menu button keep a
  margin for the focus ring inside their window;
- a ttk label and label frame have padding.

ttk::style lookup of -padding, -margin, and -tabmargins gives the value
of the theme in the modern look, and configure of those options changes
it. The classic theme keeps the values of wish.
@beetlebugorg beetlebugorg added this to the v1.0.0-beta.10 milestone Dec 4, 2026
The -padding option of a notebook went into its CSS padding too, so it
replaced the space of the theme at the edge of the notebook. It is the
space around the pages, inside the client area, as in Tk.

Two examples of docs/reference/ttk-notebook.tcl depended on the space
at the edge: the one of -width compares two widths, and the one of
identify uses a point inside the first tab.
The modern theme now gives TCombobox the margin var(--space-1), inside
its window, as room for the focus ring. The entry code draws the field,
finds the text and the arrow, and places the list in the box inside the
margin (entry.frameRect), so a click lands where the field is drawn.

The cells and the headings of a Treeview take their padding from the
scale: var(--space-2) var(--space-3). `ttk::style lookup` of -padding
for the styles Item and Heading, also Treeview.Item and
Treeview.Heading, gives the space of the part, and `configure` writes a
rule for the part ::item or ::heading.

Refs #1091
The modern sheet now takes the padding of button, entry, checkbutton,
radiobutton, and labelframe from the spacing scale: Button 4 12 (was
6 12), Entry 4 8 (5 8), Checkbutton and Radiobutton 2 (3 2), and
Labelframe 8 12 (10 12). `cget` of -padx and -pady gives the padding of
the computed style, and -highlightthickness the width of the focus
ring, when the script did not set the option (the style props padx,
pady, and focus_ring of options.zig).

`identify` of a combobox gives an empty string in its margin.

The goldens of the button, the entry, the demo, and the grapheme shot
are made again, with the approval of the owner. So are the golden of
examples/debug and the numbers of its pages and of
tests/debug-examples.sh. Three tests have the new values.

Fixes #1091
@beetlebugorg
beetlebugorg changed the base branch from ttk-padding to main December 4, 2026 20:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The rest of the theme paddings: the combobox margin, the Treeview cells, and the classic defaults

1 participant